package com.pig4cloud.pigx.contract.executer.trade.handler.impl;

import com.pig4cloud.pigx.common.customize.mysql.utils.MysqlUtil;
import com.pig4cloud.pigx.common.customize.security.utils.SecurityUtil;
import com.pig4cloud.pigx.common.customize.utils.CommonUtil;
import com.pig4cloud.pigx.contract.bo.ContractTradeNewBO;
import com.pig4cloud.pigx.contract.executer.position.supporter.PositionCalculator;
import com.pig4cloud.pigx.contract.executer.trade.handler.TradeHandlerManager;
import com.pig4cloud.pigx.contract.mapper.ContractOrderMapper;
import com.pig4cloud.pigx.contract.mapper.ContractPositionMapper;
import com.pig4cloud.pigx.contract.mapper.ContractTradeMapper;
import com.pig4cloud.pigx.contract.mongo.entity.ContractTradeMongo;
import com.pig4cloud.pigx.contract.utils.ContractUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * 默认订单撮合处理器
 *
 * @since 2022/8/17 21:26
 */
@Component
@Deprecated
public class CloseTradeHandler extends AbstractTradeHandler
        implements InitializingBean {

    protected final TradeHandlerManager tradeHandlerManager;

    /**
     * 有参构造函数
     * <p>同时给父级对象赋值
     *
     * @since 2022/8/19 14:47
     */
    public CloseTradeHandler(ContractOrderMapper contractOrderMapper,
                             ContractTradeMapper contractTradeMapper,
                             ContractPositionMapper contractPositionMapper,
                             RedisTemplate redis,
                             MongoTemplate mongo,
                             CommonUtil commonUtil,
                             MysqlUtil mysqlUtil,
                             SecurityUtil securityUtil,
                             ContractUtils contractUtils,
                             PositionCalculator positionCalculator,
                             TradeHandlerManager tradeHandlerManager) {
        super(contractOrderMapper, contractTradeMapper, contractPositionMapper, redis, mongo, commonUtil, mysqlUtil, securityUtil, contractUtils, positionCalculator);
        this.tradeHandlerManager = tradeHandlerManager;
    }

    /**
     * 当前对象创建后
     *
     * @since 2022/8/17 14:36
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        // 注册到manager
        // tradeHandlerManager.getHandlerList().add(this);
    }

    /**
     * 判断是否支持
     *
     * @param trade 成交记录
     * @return {@link boolean}
     * @since 2022/8/17 11:20
     */
    @Override
    public boolean support(ContractTradeMongo trade) {
        // 不是机器人，平仓
        return false;
    }

    /**
     * 初始化参数
     *
     * @param trade 成交记录
     * @since 2022/8/19 16:45
     */
    @Override
    protected void initParam(ContractTradeNewBO trade) {
        super.initParam(trade);


    }

    /**
     * 计算费用
     *
     * @param trade 成交记录
     * @since 2022/8/19 16:25
     */
    @Override
    protected void calculateFee(ContractTradeNewBO trade) {

    }
}
